package com.ben.multiple.message.base.tencent;

import com.ben.multiple.message.base.MessageProperties;
import com.tencentcloudapi.sms.v20190711.SmsClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author BenJin Yin
 * @date 2020/7/23
 */
@Configuration
@ConditionalOnClass(SmsClient.class)
@EnableConfigurationProperties(MessageProperties.class)
public class TencentMessageAutoConfig {

    @Bean
    @ConditionalOnProperty(value = "multiple.message.tencent")
    public TencentMessageClient tencentMessageClient(MessageProperties properties) {
        return new TencentMessageClient(properties.getTencent());
    }
}
